<?php
$hide_plus_mail=$_GET['hide_plus_mail'];
$hide_plus_mail_forward=$_GET['hide_plus_mail_forward'];

$relay_arr=array();
$relay_arr2=array();
$file_handle = fopen("/etc/passwd", "r");
while (!feof($file_handle)) {
        $line = fgets($file_handle);
        $info = explode(':',$line);
        if($info[0]!=""  && (int)$info[2] > 499){
                $relay_arr[]=$info[0];
        }
}
fclose($file_handle);


$file_handle2 = fopen("/etc/postfix/relay_recipients", "r");
while (!feof($file_handle2)) {
        $line2 = fgets($file_handle2);
        $info2 = explode(' ',$line2);
        if($info2[0]!=""){
                $relay_arr2[]=$info2[0];
	}
}
fclose($file_handle2);

$str=explode('@',$hide_plus_mail);

if(in_array($str[0],$relay_arr)){
        if(in_array($hide_plus_mail,$relay_arr2)){
                echo "0";
		return false;
        }
}

$output=array();
exec("cat /etc/postfix/relay_recipients |grep -v ".$hide_plus_mail,$output,$error);
$output[]=$hide_plus_mail." ".$hide_plus_mail_forward;
$fp=fopen("/etc/postfix/relay_recipients","w+");
foreach($output as $key=>$value){
fwrite($fp,$value."\n");
}
fclose($fp);
print_r($output);
?>
